const app = getApp();
Page({
    data: {
      ShopProductList:[],
        key:'',
        image:'',
        StatusBar: app.globalData.StatusBar,
        CustomBar: app.globalData.CustomBar,
        TabbarBot: app.globalData.tabbar_bottom,
        TabCur: 0,scrollLeft:0,
        SortMenu: [{id:0,name:"商品列表"},{id:1,name:"店铺列表"}]
    },
    onLoad: function (options) {
        let that = this;
        this.setData({
          key: options.key,
          sid: options.sid
        })
        console.log(options)
        this.search()
    },
    tabSelect(e) {
        console.log(e.currentTarget.dataset.id);
        this.setData({
            TabCur: e.currentTarget.dataset.id,
            scrollLeft: (e.currentTarget.dataset.id-1)*60
        })
    },
    getKey:function(e){
        console.log(e.detail.value.key)
        this.setData({
          key: e.detail.value.key
        })
        this.search()
    },

    search:function(){
      wx.request({
        method:'GET',
        url: 'http://localhost:8989/product/product_in_shop',
        data:{
          key: this.data.key,
          store: this.data.sid
        },
        success:(res=>{
          this.setData({
            ShopProductList: res.data.data
          })
          console.log(res)
        })
      })
    }
});
